//引入mongoose第三方模块
const mongoose = require('mongoose');
const admin = require('../route/admin');
//导入bcrypt的哈希加密
const bcrypt = require('bcryptjs');
//添加Joi模块
const Joi = require('joi');

//创建文章集合规则
const articleSchema = new mongoose.Schema({
    title: {
        type: String,
        maxlength: 10,
        minlength: 4,
        required: [true, '请填写文章标题'],
    },
    author: {
        type: mongoose.Schema.Types.ObjectId,
        ref: 'User',
        required: [true, '请传递作者'] //后者位错误信息
    },
    publishDate: {
        type: Date,
        default: Date.now
    },
    cover: {
        type: String,
        default: null,
    },
    content: {
        type: String,
    }
});
//创建文章集合
const Article = mongoose.model('Article', articleSchema);

//导出
module.exports = {
    Article
};